{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'213'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os,shutil\n",
    "os.mkdir(\"124\")\n",
    "\n",
    "shutil.copy(\"untitled.txt\",\"213\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "返回主页\t\n",
    "张波python\n",
    "\n",
    "    博客园\n",
    "    首页\n",
    "    新随笔\n",
    "    联系\n",
    "    订阅\n",
    "    管理\n",
    "\n",
    "python shutil 模块\n",
    "shutil模块\n",
    "\n",
    "    引入： import shutil\n",
    "\n",
    "copy()\n",
    "\n",
    "功能：复制文件\n",
    "格式：shutil.copy('来源文件','目标地址')\n",
    "返回值：复制之后的路径\n",
    "\n",
    "copy2()\n",
    "\n",
    "功能：复制文件，保留元数据\n",
    "格式：shutil.copy2('来源文件','目标地址')\n",
    "返回值：复制之后的路径\n",
    "\n",
    "copyfileobj()\n",
    "\n",
    "将一个文件的内容拷贝的另外一个文件当中\n",
    "格式：shutil.copyfileobj(open(来源文件,'r'),open（'目标文件','w'）)\n",
    "返回值：无\n",
    "\n",
    "copyfile()\n",
    "\n",
    "功能：将一个文件的内容拷贝的另外一个文件当中\n",
    "格式:shutil.copyfile(来源文件,目标文件)\n",
    "返回值：目标文件的路径\n",
    "\n",
    "copytree()\n",
    "\n",
    "功能：复制整个文件目录\n",
    "格式:shutil.copytree(来源目录,目标目录)\n",
    "返回值：目标目录的路径\n",
    "注意：无论文件夹是否为空，均可以复制，而且会复制文件夹中的所有内容\n",
    "\n",
    "copymode()\n",
    "\n",
    "功能：拷贝权限\n",
    "\n",
    "copystat()\n",
    "\n",
    "功能：拷贝元数据（状态）\n",
    "\n",
    "rmtree()\n",
    "\n",
    "功能：移除整个目录，无论是否空\n",
    "格式：shutil.rmtree(目录路径)\n",
    "返回值：无\n",
    "\n",
    "move()\n",
    "\n",
    "功能：移动文件或者文件夹\n",
    "格式：shutil.move(来源地址,目标地址)\n",
    "返回值：目标地址\n",
    "\n",
    "which()\n",
    "\n",
    "功能：检测命令对应的文件路径\n",
    "格式：shutil.which(‘命令字符串’)\n",
    "返回值：命令文件所在位置\n",
    "注意：window和linux不太一样。 window的命令都是.exe结尾，linux则不是\n",
    "\n",
    "disk_usage()\n",
    "\n",
    "功能：检测磁盘使用信息\n",
    "格式：disk_usage(‘盘符’)\n",
    "返回值：元组\n",
    "\n",
    "归档和解包操作\n",
    "\n",
    "    归档：将多个文件合并到一个文件当中，这种操作方式就是归档。\n",
    "\n",
    "    解包：将归档的文件进行释放。\n",
    "\n",
    "    压缩：压缩时将多个文件进行有损或者无损的合并到一个文件当中。\n",
    "\n",
    "    解压缩：就是压缩的反向操作，将压缩文件中的多个文件，释放出来。\n",
    "    注意：压缩属于归档！\n",
    "\n",
    "make_archive()\n",
    "\n",
    "功能：归档函数，归档操作\n",
    "格式：shutil.make_archive('目标文件路径','归档文件后缀','需要归档的目录')\n",
    "返回值：归档文件的最终路径\n",
    "\n",
    "unpack_archive()\n",
    "\n",
    "功能：解包操作\n",
    "格式：shutil.unpack_archive('归档文件路径','解包目标文件夹')\n",
    "返回值:None\n",
    "注意：文件夹不存在会新建文件夹\n",
    "\n",
    "get_archive_formats()\n",
    "\n",
    "功能：获取当前系统已注册的归档文件格式（后缀）\n",
    "格式：shutil.get_archive_formats()\n",
    "返回值：列表   [(后缀,解释),(后缀,解释),(后缀,解释)...]\n",
    "\n",
    "get_unpack_formats()\n",
    "\n",
    "功能：获取当前系统已经注册的解包文件格式(后缀)\n",
    "格式:shutil.get_unpack_formats()\n",
    "返回值：列表   [(后缀,解释),(后缀,解释),(后缀,解释)...]\n",
    "\n",
    "分类: python 常用模块\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
